<?php

function combine($arr) {
	$count = count($arr);
	$n = 0;
	for ($i = 0; $i < $count; $i++) {
		if ($count - $i > 0 && $count - $i < $count) {
			for ($j = 0; $j < $count; $j++) {
				if ($i == $j) {
					break;
				}
				for ($k = 0; $k < $count; $k++) {
					if ($k == $i || $k == $j) {
						break;
					}
					for ($l = 0; $l < $count; $l++) {
						if ($l == $i || $l == $j || $l == $k) {
							break;
						}
						print_r($arr[$l] . $arr[$k] . $arr[$j] . $arr[$i] . " ");
						$n++;
					}
				}
			}
		}
	}
	print_r($n);
}

print_r(combine(range('a', 'z')));
